package com.tzy.note.base.thread.create;

import com.tzy.note.base.util.Downloader;

/**
 * 继承Thread类多线程下载
 */
public class CreateThread1_Downloader extends Thread {
    //网络资源url
    private String url;
    //保存的文件名(含路径)
    private String pathFileName;

    public CreateThread1_Downloader(String url,String pathFileName){
        this.url = url;
        this.pathFileName = pathFileName;
    }

    @Override
    public void run() {
        Downloader.download(url,pathFileName);
        System.out.println("线程: " + Thread.currentThread().getName() + " 下载了" + pathFileName);
    }

    public static void main(String[] args) {
        CreateThread1_Downloader cd1 = new CreateThread1_Downloader("https://www.baidu.com/favicon.ico","1.ico");
        CreateThread1_Downloader cd2 = new CreateThread1_Downloader("https://www.baidu.com/img/flexible/logo/pc/result.png","2.png");
        CreateThread1_Downloader cd3 = new CreateThread1_Downloader("https://dss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/topnav/baiduyun@2x-e0be79e69e.png","3.png");
        cd1.start();
        cd2.start();
        cd3.start();
    }
}
